home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1994-05-15 | 4.6 KB | 178 lines |
- >!RunImage
- Program Test Program For Sending a User Message
- init
- quit%:
- start of poll loop
- "Wimp_Poll",0,bk%
- reason%
- reason%
- 2 :
- "Wimp_OpenWindow",,bk%
- 3 :
- "Wimp_CloseWindow",,bk%
- 6 :
- button
- 9 :
- menuselect
- 17,18:
- message
- "Wimp_CloseDown"
- button
- bk%!8
- read button state
- bk%!12=-2
- 5
- if Menu pressed over iconbar, create menu
- 0
- "Wimp_CreateMenu",,menu%,!bk%-64,184
- bk%!12
-
- ,
- <SELECT> used on iconbar icon..
- !bk%= mainw%
- !(
- "Wimp_GetWindowState",,bk%
- bk%!28 = -1
- #$
- "Wimp_OpenWindow",,bk%
-
- mainw%
- %@
- MessageSend("Proggy2:"+
- shell_IconGetData(mainw%,1))
- menuselect
- button%
- "Wimp_GetPointerInfo",,bk%+256
- read button state
- .+button%=bk%!264
- !bk%
- quit if item 1 chosen
- 2$ quit%=
-
- re-open menu if Adjust was pressed
- button%=1
- "Wimp_CreateMenu",,menu%:
- message
- bk%!16
- :G
- read message action code
- 0:quit%=
- :
- quit if Quit message received
- string(a%)
- convert a null-terminated string into CR-terminated
- ?a%<>0
- a$+=
- ?a%:a%+=1
- bk% 2000,menu% 75,ind% 2000,name% 11
- quit%=0:name$="Proggy1"
- err%=0
- "OS_ReadVarVal","Proggy1$Dir",bk%,255,0,3
- ,,i%
- bk%?i%=13:dir$=$bk%
- "Wimp_Initialise",200,&4B534154,name$
- error:
- "Wimp_OpenTemplate",,dir$+".Templates"
- i%=ind%
- infohan%=
- create("InfoBox")
- mainw% =
- create("mainw")
- "Wimp_CloseTemplate"
- U%!bk%=-1:bk%!4=0:bk%!8=0:bk%!12=68
- V/bk%!16=68:bk%!20=&3002:$(bk%+24)="!Proggy1"
- "Wimp_CreateIcon",,bk%
- setupmenu(menu%)
- setupmenu(m%)
- $m%,num%:len%=
- ($m%)-2
- ]!m%!12=&70207:m%!20=44:m%!24=0
- m%+=28:
- i%=1
- num%
- !m%=-&80*(i%=num%):
- m%!4
- `# m%!8=&7009021:
- a$:$(m%+12)=a$
- a$>len% len%=
- m%+=24
- :menu%!16=16*(len%+1)
- create(a$)
- $name%=a$
- "Wimp_LoadTemplate",,bk%,i%,ind%+2000,-1,name%,0
- ,,i%
- "Wimp_CreateWindow",,bk%
- handle%
- =handle%
- error
- report(
- $+" - internal error code "+
- "Wimp_CloseDown"
- report(a$,x%)
- !bk%=1:$(bk%+4)=a$+
- "Wimp_ReportError",bk%,x%,name$
- Proggy1,2,infohan%,Info,-1,Quit
- --- Memory Management Routines ----------------------------------------
- _heap_get(size%)
- ptr%,heap%,flags%
- Returns pointer to new memory block unless claim fails
- in which case -1 is returned
- First find start address of RMA..
- "OS_ReadDynamicArea",1
- heap%
- Now claim memory, trapping errors by using X form of SWI..
- "XOS_Module",6,,,size%
- ,,ptr%;flags%
- If error occured return -1, else return address of allocated
- block
- (flags%
- ptr% = -1
- = ptr%
- _heap_release(
- ptr%)
- maxfree%,nrpages%,flags%
- Returns 0 if block released OK
- Returns -1 if operation failed (i.e. block doesn't exist)
- "XOS_Module",7,,ptr%
- ;flags%:
- Free the block
- (flags%
- 1) = 0
- Block was released successfully...
- ptr% = 0
- Error occured trying to free the block, return -1 to signal to the
- program that something went wrong (normally the program would ignore
- this anyway)
- ptr% = -1
- MessageSend(msg$)
- msg_blk%,m_len%
- 'm_len% = (
- msg$ + 24)
- 'msg_blk% =
- _heap_get(m_len%)
- -msg_blk%!00 = m_len%:
- Size of message
- Imsg_blk%!12 = 0 :
- your_ref (0 = original message not a reply)
- 6msg_blk%!16 = &43B00:
- User message reason code
- the 'data' part of the message is simply a zero terminated string..
- "$(msg_blk% + 20) = msg$ +
- send message with reason code 17 (UserMessage, no reply required)
- the 0 passed as the third parameter means broadcast to all tasks..
- "XWimp_SendMessage",17,msg_blk%,0
- _heap_release(msg_blk%)
- shell_IconGetData(whandle%,ihandle%)
- result$,icon_blk%
- icon_blk%=
- _heap_get(40)
- icon_blk%!0=whandle%
- icon_blk%!4=ihandle%
- "Wimp_GetIconState",,icon_blk%
- (icon_blk%!24
- (1<<8))<>0
- result$=$(icon_blk%!28)
- result$=$(icon_blk%+28)
- _heap_release(icon_blk%)
- =result$
-